Merge pull request #6795 from mikeller/fix_changed_defines_in_3_5
[betaflight.git] / docs / development / Building in Windows.md
blobe39274eeac42826cb99910fb5ae74d14edd7851d
1 # Building in windows
4 ## Bash On Windows 10
6 A new feature in Windows 10 allows any developer to quickly and easily run an entire linux subsystem in windows and access it via a bash terminal. This gives developers full use of the entire linux OS and all of the great existing linux tools and programs. When Bash for Windows is up and running it feels like you sshed into a full linux box, except the linux distro is actually running alongside windows locally.
8 If you use Bash on Windows you can easily build cleanflight exactly as you would for Ubuntu. (the linux distro running on Windows is Ubuntu Trusty)
10 Setup for Bash on Windows is very easy and takes less than 5 minutes. [For instructions follow the official guide here.](https://msdn.microsoft.com/commandline/wsl/install_guide)
12 Once you have Bash On Windows running you can follow the "Building in Ubuntu" instructions for building cleanfight.
14 ##Setup Cygwin
16 download the Setup*.exe from https://www.cygwin.com/
18 ![Cygwin Installation](assets/001.cygwin_dl.png)
20 Execute the download Setup and step through the installation  wizard (no need to customize the settings here). Stop at the  "Select Packages" Screen and select the following Packages
21 for Installation:
23 - Devel/git
24 - Devel/bash-completion (was git-completion, Optional)
25 - Devel/make
26 - Devel/binutils
27 - Editors/vim    
28 - Editors/vim-common (Optional)
29 - Shells/mintty (should be already selected)
31 ![Cygwin Installation](assets/002.cygwin_setup.png)
33 ![Cygwin Installation](assets/003.cygwin_setup.png)
35 ![Cygwin Installation](assets/004.cygwin_setup.png)
37 ![Cygwin Installation](assets/005.cygwin_setup.png)
39 ![Cygwin Installation](assets/006.cygwin_setup.png)
42 Continue with the Installation and accept all autodetected dependencies.
44 ![Cygwin Installation](assets/007.cygwin_setup.png)
47 ##Setup GNU ARM Toolchain
49 ----------
51 versions do matter, 5.4 is known to work well. Download this version from https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q2-update/+download/gcc-arm-none-eabi-5_4-2016q2-20160622-win32.zip 
54 Extract the contents of this archive to any folder of your choice, for instance ```C:\dev\gcc-arm```. 
56 ![GNU ARM Toolchain Setup](assets/008.toolchain.png)
58 add the "bin" subdirectory to the PATH Windows environment variable: ```%PATH%;C:\dev\gcc-arm\bin```
60 ![GNU ARM Toolchain Setup](assets/009.toolchain_path.png)
62 ![GNU ARM Toolchain Setup](assets/010.toolchain_path.png)
64 ## Checkout and compile Cleanflight
66 Head over to the Cleanflight Github page and grab the URL of the GIT Repository: "https://github.com/cleanflight/cleanflight.git"
68 Open the Cygwin-Terminal, navigate to your development folder and use the git commandline to checkout the repository:
70 ```bash
71 cd /cygdrive/c/dev
72 git clone https://github.com/cleanflight/cleanflight.git
73 ```
74 ![GIT Checkout](assets/011.git_checkout.png)
76 ![GIT Checkout](assets/012.git_checkout.png)
78 To compile your Cleanflight binaries, enter the cleanflight directory and build the project using the make command. You can append TARGET=[HARDWARE] if you want to build anything other than the default NAZE target:
80 ```bash
81 cd cleanflight
82 make TARGET=NAZE
83 ```
85 ![GIT Checkout](assets/013.compile.png)
87 within few moments you should have your binary ready:
89 ```bash
90 (...)
91 arm-none-eabi-size ./obj/main/cleanflight_NAZE.elf
92    text    data     bss     dec     hex filename
93   95388     308   10980  106676   1a0b4 ./obj/main/cleanflight_NAZE.elf
94 arm-none-eabi-objcopy -O ihex --set-start 0x8000000 obj/main/cleanflight_NAZE.elf obj/cleanflight_NAZE.hex
95 ```
97 You can use the Cleanflight-Configurator to flash the ```obj/cleanflight_NAZE.hex``` file.
99 ## Updating and rebuilding
101 Navigate to the local cleanflight repository and use the following steps to pull the latest changes and rebuild your version of cleanflight:
103 ```bash
104 cd /cygdrive/c/dev/cleanflight
105 git reset --hard
106 git pull
107 make clean TARGET=NAZE -j16 -l
108 make
111 You may want to remove -j16 -l if your having a hard time narrowing down errors.  It does multithreaded make, however it makes it harder to know which warning or error comes from which file.